package com.electric.flinkcep.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Objects;

/**
 * 事件数据模型
 * 用于表示从Kafka接收的事件数据
 */
public class Event implements Serializable {
    
    @JsonProperty("id")
    private String id;
    
    @JsonProperty("type")
    private String type;
    
    @JsonProperty("source")
    private String source;
    
    @JsonProperty("timestamp")
    private long timestamp;
    
    @JsonProperty("data")
    private String data;
    
    @JsonProperty("severity")
    private String severity;
    
    @JsonProperty("userId")
    private String userId;
    
    // 默认构造函数
    public Event() {
    }
    
    // 全参构造函数
    public Event(String id, String type, String source, long timestamp, String data, String severity, String userId) {
        this.id = id;
        this.type = type;
        this.source = source;
        this.timestamp = timestamp;
        this.data = data;
        this.severity = severity;
        this.userId = userId;
    }
    
    // Getter和Setter方法
    public String getId() {
        return id;
    }
    
    public void setId(String id) {
        this.id = id;
    }
    
    public String getType() {
        return type;
    }
    
    public void setType(String type) {
        this.type = type;
    }
    
    public String getSource() {
        return source;
    }
    
    public void setSource(String source) {
        this.source = source;
    }
    
    public long getTimestamp() {
        return timestamp;
    }
    
    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }
    
    public String getData() {
        return data;
    }
    
    public void setData(String data) {
        this.data = data;
    }
    
    public String getSeverity() {
        return severity;
    }
    
    public void setSeverity(String severity) {
        this.severity = severity;
    }
    
    public String getUserId() {
        return userId;
    }
    
    public void setUserId(String userId) {
        this.userId = userId;
    }
    
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Event event = (Event) o;
        return timestamp == event.timestamp &&
                Objects.equals(id, event.id) &&
                Objects.equals(type, event.type) &&
                Objects.equals(source, event.source) &&
                Objects.equals(data, event.data) &&
                Objects.equals(severity, event.severity) &&
                Objects.equals(userId, event.userId);
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(id, type, source, timestamp, data, severity, userId);
    }
    
    @Override
    public String toString() {
        return "Event{" +
                "id='" + id + '\'' +
                ", type='" + type + '\'' +
                ", source='" + source + '\'' +
                ", timestamp=" + timestamp +
                ", data='" + data + '\'' +
                ", severity='" + severity + '\'' +
                ", userId='" + userId + '\'' +
                '}';
    }
}